//https://leetcode.cn/problems/container-with-most-water/?envType=study-plan-v2&envId=top-100-liked
//解题思路：https://biaodigit.github.io/LeetCode/0011/#%E8%A7%A3%E9%A2%98%E6%80%9D%E8%B7%AF%EF%BC%9A%E5%8F%8C%E6%8C%87%E9%92%88%E6%B3%95
//1.while 双指针：谁短移动谁！O(n)
//2.两层for循环；暴力解法 O(n2)

#include <iostream>
#include <vector>
#include <map>
#include<unordered_map>
using namespace std;

class Solution {
public:
    int maxArea(vector<int>& height) {
        int i = 0, j = height.size() - 1, res = 0;
        while(i < j) {
            res = height[i] < height[j] ? 
                max(res, (j - i) * height[i++]): 
                max(res, (j - i) * height[j--]); 
        }
        return res;
    }
};

